#!/usr/bin/php
<?php

require(dirname(__FILE__)."/../src_v2/classes/Token.php");


$uname   = 'piotr';
$pwd_md5 = md5('pass');

$token = Token::generate($uname, $pwd_md5, 1800);

$cookie_struct = array( 'token' => $token);
$cookie_json   = json_encode( $cookie_struct );


$_COOKIE['ParaSite_Auth'] = $cookie_json;

//$_POST['json']= '{"operation": "chat_post_msg", "postback": "hesthest", "param": { "text": "Hejji" }}';

require_once(dirname(__FILE__)."/../src_v2/classes/init.php");

$dbl = $PARAPARA->dblayer;
$status = $dbl->create_forum_thread( 'heste', 'piotr', 1, 'Hvorfor kan man ikke?', 'jo, man kan!', '0.0.0.0' );
echo "Created thread $tid \n";

//Create 5 children with children
for($i = 0; $i < 5; $i++) {
    $mid = $dbl->create_forum_message( 
        $status['thread_id'],
        $status['message_id'],
        'Tossen',
        2,
        'Bisonokser styrer folketinget',
        'Det ses og blah asf asf asdf sadf sadf asdf',
        '0.0.0.0'
        );

    // create anonymous child for each child
    $mid = $dbl->create_forum_message( 
        $status['thread_id'],
        $mid,
        'Dominic',
        '',
        'Hallo. I greet you. Buy VlA6rA online',
        'BUY BUY BISAFASFASDASDF',
        '0.0.0.0'
        );

}

//require(dirname(__FILE__)."/../src_v2/remote.php");
//echo "\n---end of response \n";

echo $dbl->latest_query, "\n";
echo $dbl->mysql_error, "\n";

?>